package com.wits.platform.common.tag;

import java.io.IOException;
import java.util.Date;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;


public class Long2DateString extends TagSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 584199743058673517L;
	
	private String pattern;
	
	private Long value;

	@Override
	public int doStartTag() throws JspException {
		java.text.SimpleDateFormat formater = new java.text.SimpleDateFormat(pattern);
		String date ="";
		if(value>0){
			date=formater.format(new Date(value));
		}
		JspWriter out = pageContext.getOut();
		try {
			out.print(date);
		} catch (IOException e) {
			e.printStackTrace();
		}
		// doStartTag() 方法返回 SKIP_BODY 。当然其原因是我们的简单日期标记没有正文。
		return Tag.SKIP_BODY;
	}


	public void setPattern(String pattern) {
		this.pattern = pattern;
	}
	


	public void setValue(Long value) {
		this.value = value;
	}

}